{% extends "layout/basic.html" %}
{% block content %}
<div class="row">
  <div class="medium-9 columns">
    <div class="section">
      <div class="section__body">
        <form method="post">
          {{ form.form_text({
              columns:12,
              label:'Title',
              name:'title',
              placeholder:_('title'),
              value:tdoc['title']|default(''),
              autofocus:true
          }) }}
          <div class="row">
            {{ form.form_text({
                columns:3,
                label:'Begin Date',
                name:'beginAtDate',
                placeholder:'YYYY-mm-dd',
                value:dateBeginText,
                date:true,
                row:false
            }) }}
            {{ form.form_text({
                columns:2,
                label:'Begin Time',
                name:'beginAtTime',
                placeholder:'HH:MM',
                value:timeBeginText,
                time:true,
                row:false
            }) }}
            {{ form.form_text({
                columns:3,
                label:'End Date',
                name:'penaltySinceDate',
                placeholder:'YYYY-mm-dd',
                value:datePenaltyText,
                date:true,
                row:false
            }) }}
            {{ form.form_text({
                columns:2,
                label:'End Time',
                name:'penaltySinceTime',
                placeholder:'HH:MM',
                value:timePenaltyText,
                time:true,
                row:false
            }) }}
            {{ form.form_text({
                row:false,
                last_column:true,
                columns:2,
                label:'Extension (days)',
                name:'extensionDays',
                value:extensionDays
            }) }}
          </div>
          <div class="row">
            {{ form.form_text({
                row:false,
                columns:6,
                label:'Assign',
                name:'assign',
                placeholder:_('Group / UID'),
                value:tdoc.assign|default('')
            }) }}
            {{ form.form_text({
                row:false,
                last_column:true,
                columns:6,
                label:'Homework Maintainer',
                name:'maintainer',
                help_text:_('Allow to maintain this {0}').format(_('homework')),
                value:tdoc.maintainer|default('')
            }) }}
          </div>
          <div class="row"><div class="columns">
            <label>
              {{ _('Extension Score Penalty') }}
              <textarea name="penaltyRules" class="monospace textbox" data-yaml>{% if tdoc %}{{ penaltyRules }}{% else %}{% include 'partials/homework_default_penalty_rules.yaml' %}{% endif %}</textarea>
            </label>
          </div></div>
          {{ form.form_text({
              columns:null,
              label:'Problems',
              name:'pids',
              value:pids
          }) }}
          {{ form.form_textarea({
              columns:null,
              label:'Content',
              name:'content',
              value:tdoc['content']|default(''),
              markdown:true
          }) }}
          {{ form.form_text({
              columns:12,
              label:'Submission language limit',
              name:'langs',
              value:tdoc.langs|default(''),
              placeholder:_("Seperated with ','"),
              row:true
          }) }}
          <div class="row"><div class="columns">
          {% if page_name == 'homework_edit' %}
            <button name="operation" value="update" type="submit" class="rounded primary button">
              {{ _('Update') }}
            </button>
            <button name="operation" value="update" type="submit" formaction="{{ url('homework_create') }}" class="rounded button">
              {{ _('Clone') }}
            </button>
            {% if handler.user.own(tdoc) or handler.user.hasPerm(perm.PERM_EDIT_HOMEWORK) %}
              <button name="operation" value="delete" type="submit" class="rounded button">
                {{ _('Delete') }}
              </button>
            {% endif %}
          {% else %}
            <button name="operation" value="update" type="submit" class="rounded primary button">
              {{ _('Create') }}
            </button>
          {% endif %}
            <button type="button" class="rounded button" onclick="window.history.go(-1)">
              {{ _('Cancel') }}
            </button>
          </div></div>
        </form>
      </div>
    </div>
  </div>
  <div class="medium-3 columns">
    {% include 'components/md_hint.html' %}
  </div>
</div>
{% endblock %}